package com.xzl.xep.common.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Mar 7, 2008 1:35:43 PM
 * @version $Id: NumberUtil.java,v 1.1 2013/10/23 03:26:18 haoxz11 Exp $
 */
public class NumberUtil {

	/**
	 * 与记算操作
	 * @param value1
	 * @param value2
	 * @return
	 */
	public static boolean andOperate(int value1,int value2){
		if((value1 & value2)==value2){
			return true;
		}
		return false;
	}
	
	public static int getRandomInt(int min,int max){
		return (int)Math.round(Math.random()*max+min);
	}
	
	public static int parseInt(String in){
		int re = 0;
		if(!StringUtils.isEmpty(in)){
			try {
				re = Integer.parseInt(in);
			} catch (Exception e) {
				//e.printStackTrace();
				re=0;
			}
		}
		return re;
	}
	
	public static long parseLong(String in){
		long re = 0;
		if(!StringUtils.isEmpty(in)){
			try {
				re = Long.parseLong(in);
			} catch (Exception e) {
				//e.printStackTrace();
				re=0;
			}
		}
		return re;
	}
	
	public static double parseDouble(String in){
		double re = 0;
		if(!StringUtils.isEmpty(in)){
			try {
				re = Double.parseDouble(in);
			} catch (Exception e) {
				//e.printStackTrace();
				re=0;
			}
		}
		return re;
	}
	
	public static int[] parseInt(String[] in){
		int[] arr=new int[in.length];
		int i=0;
		for(String s:in){
			arr[i]=parseInt(s);
			i++;
		}
		return arr;
	}
}
